package com.kaifamiao.decimal;

import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;

public class TestMathContext {

    public static void main(String[] args) {

        final MathContext mc = new MathContext( 10 , RoundingMode.HALF_UP );

        BigDecimal x = BigDecimal.valueOf( 123456789L , 3 );
        System.out.println( x );

        BigDecimal y = BigDecimal.valueOf( 414, 2 );
        System.out.println( y );

        System.out.println( x.divide( y , RoundingMode.HALF_UP ) );

        // 根据给定的 MathContext 实现除法运算
        System.out.println( x.divide( y , mc ) );

    }

}
